<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>专线管理</title>
  <link href="/assets/css/admin/reset.css" rel="stylesheet" type="text/css">
  <link href="/assets/css/admin/zh-cn-system.css" rel="stylesheet" type="text/css">
  <link href="/assets/css/admin/table_form.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" type="text/css" href="/assets/css/admin/style/zh-cn-styles1.css" title="styles1" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="/assets/css/admin/style/zh-cn-styles2.css" title="styles2" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="/assets/css/admin/style/zh-cn-styles3.css" title="styles3" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="/assets/css/admin/style/zh-cn-styles4.css" title="styles4" media="screen">
  <script type="text/javascript" src="/assets/js/admin/jquery.min.js"></script>
  <script type="text/javascript" src="/assets/js/admin/jquery.cookie.js"></script>
  <script type="text/javascript" src="/assets/js/admin/styleswitch.js"></script>
  <script type="text/javascript" src="/assets/js/admin/admin_common.js"></script>
</head>
 <style type="text/css">
    html{
        _overflow-y:scroll
    }
     #search{
        margin: 20px;
     }
    #ord{

        margin: 20px;
        margin-left: 20px;
    }
    table{
        width:100%;
        margin: auto;
        text-align: center;
        background: #fff;
    }
    th{
        background:rgb(18,162,225);
        color: #fff;
        border:solid 1px #fff;
    }
    td{
        background: #ccc;
        border:solid 1px #fff;
    }
</style>
<body>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <a class="add fb" href="/Admin/Zhuanxian/add"><em>添加专线</em></a>&nbsp;&nbsp;&nbsp;<a class="" href="/Admin/Zhuanxian/index"><em>专线管理</em></a>
    </div>
</div>


  <div class="pad-lr-10 table-list">
      <form action="" method="post">
      <div id="search">
          渠道：
          <select name="channel_id" id="channel_id">
              <option value="">请选择</option>
              <?php if(is_array($channel)): foreach($channel as $key=>$val): ?><option value="<?php echo ($val['id']); ?>"><?php echo ($val['company']); ?></option><?php endforeach; endif; ?>
          </select>
          分区：
          <select name="partition_id" id="partition_id">
              <option value="">请选择</option>
              <?php if(is_array($partition)): foreach($partition as $key=>$val): ?><option value="<?php echo ($val['id']); ?>"><?php echo ($val['partition']); ?></option><?php endforeach; endif; ?>
          </select>
          国家：
          <select name="country_id" id="country_id">
              <option value="">请选择</option>
              <?php if(is_array($country)): foreach($country as $key=>$val): ?><option value="<?php echo ($val['id']); ?>"><?php echo ($val['ename']); ?>&nbsp;&nbsp;<?php echo ($val['cname']); ?></option><?php endforeach; endif; ?>
          </select>
      </div>

      </form>
      <script type="text/javascript">
      var idTmr;
      function  getExplorer() {
          var explorer = window.navigator.userAgent ;
          //ie
          if (explorer.indexOf("MSIE") >= 0) {
              return 'ie';
          }
          //firefox
          else if (explorer.indexOf("Firefox") >= 0) {
              return 'Firefox';
          }
          //Chrome
          else if(explorer.indexOf("Chrome") >= 0){
              return 'Chrome';
          }
          //Opera
          else if(explorer.indexOf("Opera") >= 0){
              return 'Opera';
          }
          //Safari
          else if(explorer.indexOf("Safari") >= 0){
              return 'Safari';
          }
      }
      function method1(tableid) {//整个表格拷贝到EXCEL中
          if(getExplorer()=='ie')
          {
              var curTbl = document.getElementById(tableid);
              var oXL = new ActiveXObject("Excel.Application");

              //创建AX对象excel
              var oWB = oXL.Workbooks.Add();
              //获取workbook对象
              var xlsheet = oWB.Worksheets(1);
              //激活当前sheet
              var sel = document.body.createTextRange();
              sel.moveToElementText(curTbl);
              //把表格中的内容移到TextRange中
              sel.select();
              //全选TextRange中内容
              sel.execCommand("Copy");
              //复制TextRange中内容
              xlsheet.Paste();
              //粘贴到活动的EXCEL中
              oXL.Visible = true;
              //设置excel可见属性

              try {
                  var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");
              } catch (e) {
                  print("Nested catch caught " + e);
              } finally {
                  oWB.SaveAs(fname);

                  oWB.Close(savechanges = false);
                  //xls.visible = false;
                  oXL.Quit();
                  oXL = null;
                  //结束excel进程，退出完成
                  //window.setInterval("Cleanup();",1);
                  idTmr = window.setInterval("Cleanup();", 1);

              }

          }
          else
          {
              tableToExcel('ta');
          }
      }
      function Cleanup() {
          window.clearInterval(idTmr);
          CollectGarbage();
      }
      var tableToExcel = (function() {
          var uri = 'data:application/vnd.ms-excel;base64,',
                  template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
                  base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },
                  format = function(s, c) {
                      return s.replace(/{(\w+)}/g,
                              function(m, p) { return c[p]; }) }
          return function(table, name) {
              if (!table.nodeType) table = document.getElementById(table)
              var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
              window.location.href = uri + base64(format(template, ctx))
          }
      })();
  </script>
      <button onclick="javascript:method1('ta')">导出EXCEL表</button>
      <form name="myform" id="myform" action="" method="post">
          <div id="ord">
              <table cellspacing="1" id="ta">
                  <tr>
                      <th>分区</th>
                      <th>国家区域</th>
                      <th>渠道</th>
                      <th>燃油</th>
                      <th>底重(kg)</th>
                      <th>底价(RMB)</th>
                      <th>每段最小重(kg)</th>
                      <th>每段最大重(kg)</th>
                      <th>续重(kg)</th>
                      <th>续重价(RMB)</th>
                      <th>操作</th>
                  </tr>
                  <?php if(is_array($data)): foreach($data as $key=>$value): ?><tr class="data">
                          <td><?php echo ($value['partition']); ?></td>
                          <td><?php echo ($value['cname']); ?>&nbsp;&nbsp;<?php echo ($value['ename']); ?></td>
                          <td><?php echo ($value['company']); ?></td>
                          <?php if($value['fuel']==0): ?><td>已含燃油</td>
                          <?php else: ?>
                              <td><?php echo ($value['fuel']); ?>%</td><?php endif; ?>
                          <td><?php echo ($value['start_weight']); ?></td>
                          <td><?php echo ($value['start_fare']); ?></td>
                          <td><?php echo ($value['stage_min_weig']); ?></td>
                          <td><?php echo ($value['stage_max_weig']); ?></td>
                          <td><?php echo ($value['add_weig']); ?></td>
                          <td><?php echo ($value['add_weig_price']); ?></td>
                          <td>
                              <a href="/Admin/Zhuanxian/edit/nid/<?php echo ($value['id']); ?>">修改</a> |
                              <a onclick="return ConfirmDel();" href="/Admin/Zhuanxian/del/nid/<?php echo ($value['id']); ?>">删除</a>
                          </td>
                      </tr><?php endforeach; endif; ?>
                  <tr class="data">
                      <td colspan="11"><?php echo ($page); ?></td>
                  </tr>
              </table>
          </div>

      </form>
    </div>
<script type="text/javascript">
    function queren(t){
        if(confirm("确认已付款吗")){
            $.getJSON("/Admin/Zhuanxian/affirm",{ord_status:1,nid:t},function(msg){
                if(msg){
                    document.location.href="/Admin/Zhuanxian";
                }else{
                    alert("确认失败");
                }
            })
        }
    }
    $("#channel_id").change(function(){
        var arr={};
        arr.channel_id =$(this).val();
        if($("#partition_id").val()){
            arr.partition_id=$("#partition_id").val();
        }
        if($("#country_id").val()){
            arr.country_id=$("#country_id").val();
        }
        $.getJSON("/Admin/Zhuanxian/search",arr,function(msg){
            $("#ord tr.data").remove();
            if(msg){
                var cont;
                for(var i in msg){
                    cont+="<tr class='data'><td>"+msg[i].partition+"</td><td>"+msg[i].cname+"&nbsp;&nbsp;"+msg[i].ename+"</td><td>"+msg[i].company+"</td>";
                    if(msg[i].fuel==0){
                        cont+="<td>已含燃油</td>";
                    }else{
                        cont+="<td>"+msg[i].fuel+"%</td>" ;
                    }
                    cont+="<td>"+msg[i].start_weight+"</td><td>"+msg[i].start_fare+"</td><td>"+msg[i].stage_min_weig+"</td><td>"+msg[i].stage_max_weig+"</td><td>"+msg[i].add_weig+"</td><td>"+msg[i].add_weig_price+"</td>";
                    cont+="<td><a href='/Admin/Zhuanxian/edit/nid/"+msg[i].id+"'>修改</a> \| <a onclick='return ConfirmDel()' href='/Admin/Zhuanxian/del/nid/"+msg[i].id+"'>删除</a></td></tr>";
                }
                $(cont).appendTo("#ord table");
            }else{
                $("#ord tr.data").remove();
                var cont="<tr class='data'><td colspan='11'>没有你要找的数据</td></tr>";
                $(cont).appendTo("#ord table");
            }
        })
    })
    $("#partition_id").change(function(){
        var arr={};
        arr.partition_id=$(this).val();
        if($("#channel_id").val()){
            arr.channel_id=$("#channel_id").val();
        }
        if($("#country_id").val()){
            arr.country_id=$("#country_id").val();
        }
        $.getJSON("/Admin/Zhuanxian/search",arr,function(msg){
            $("#ord tr.data").remove();
            if(msg){
                var cont;
                for(var i in msg){
                    cont+="<tr class='data'><td>"+msg[i].partition+"</td><td>"+msg[i].cname+"&nbsp;&nbsp;"+msg[i].ename+"</td><td>"+msg[i].company+"</td>";
                    if(msg[i].fuel==0){
                        cont+="<td>已含燃油</td>";
                    }else{
                        cont+="<td>"+msg[i].fuel+"%</td>" ;
                    }
                    cont+="<td>"+msg[i].start_weight+"</td><td>"+msg[i].start_fare+"</td><td>"+msg[i].stage_min_weig+"</td><td>"+msg[i].stage_max_weig+"</td><td>"+msg[i].add_weig+"</td><td>"+msg[i].add_weig_price+"</td>";
                    cont+="<td><a href='/Admin/Zhuanxian/edit/nid/"+msg[i].id+"'>修改</a> \| <a onclick='return ConfirmDel()\;' href='/Admin/Zhuanxian/del/nid/"+msg[i].id+"'>删除</a></td></tr>";
                }
                $(cont).appendTo("#ord table");
            }else{
                $("#ord tr.data").remove();
                var cont="<tr class='data'><td colspan='11'>没有你要找的数据</td></tr>";
                $(cont).appendTo("#ord table");
            }
        })
    })
    $("#country_id").change(function(){
        var arr={};
        arr.country_id =$(this).val();
        if($("#partition_id").val()){
            arr.partition_id=$("#partition_id").val();
        }
        if($("#channel_id").val()){
            arr.channel_id=$("#channel_id").val();
        }
        $.getJSON("/Admin/Zhuanxian/search",arr,function(msg){
            $("#ord tr.data").remove();
            if(msg){
                var cont;
                for(var i in msg){
                    cont+="<tr class='data'><td>"+msg[i].partition+"</td><td>"+msg[i].cname+"&nbsp;&nbsp;"+msg[i].ename+"</td><td>"+msg[i].company+"</td>";
                    if(msg[i].fuel==0){
                        cont+="<td>已含燃油</td>";
                    }else{
                       cont+="<td>"+msg[i].fuel+"%</td>" ;
                    }
                    cont+="<td>"+msg[i].start_weight+"</td><td>"+msg[i].start_fare+"</td><td>"+msg[i].stage_min_weig+"</td><td>"+msg[i].stage_max_weig+"</td><td>"+msg[i].add_weig+"</td><td>"+msg[i].add_weig_price+"</td>";
                    cont+="<td><a href='/Admin/Zhuanxian/edit/nid/"+msg[i].id+"'>修改</a> \| <a onclick='return ConfirmDel()\;' href='/Admin/Zhuanxian/del/nid/"+msg[i].id+"'>删除</a></td></tr>";
                }
                $(cont).appendTo("#ord table");
            }else{

                var cont="<tr class='data'><td colspan='11'>没有你要找的数据</td></tr>";
                $(cont).appendTo("#ord table");
            }
        })
    })

</script>

  </body>
  </html>